package com.bckj.fastboot.core.extra.relational.configuration;

import com.bckj.fastboot.core.sql.SqlCondition;
import lombok.Data;

/**
 * RelationalConfig
 *
 * @author wfc
 **/
@Data
public class RelationalGlobalConfig {

    private static final RelationalGlobalConfig INSTANCE = new RelationalGlobalConfig();

    private SqlCondition whereCondition = SqlCondition.NOT_NULL;

    private RelationalGlobalConfig() { }

    public static RelationalGlobalConfig getInstance() {
        return INSTANCE;
    }

    public void config(RelationalProperties properties) {
        if (properties.getWhereCondition() != null) {
            SqlCondition whereCondition = switch (properties.getWhereCondition()) {
                case "NOT_EMPTY" -> SqlCondition.NOT_EMPTY;
                case "NOT_BLANK" -> SqlCondition.NOT_BLANK;
                default -> SqlCondition.NOT_NULL;
            };
            INSTANCE.setWhereCondition(whereCondition);
        }
    }
}
